<template>
  <div class="model-container">
    <div class="listName">编辑信息</div>

    <el-card style="margin-top: 10px">
      <el-form ref="dialogBindData" :model="dialogBindData" :rules="rules" label-width="10%" status-icon>
        <el-row>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
            <el-form-item label="主题">
              <el-input v-model="dialogBindData.paramName" :disabled="disableIinput" size="small" type="text" placeholder="请输入主题" />
            </el-form-item>
            <el-form-item>
              <div class="tinymcClass">
                <Tinymce v-model="dialogBindData.paramValue" />
              </div>
            </el-form-item>
            <div class="btns-wrapper">
              <el-button :loading="buttonState" type="primary" size="small" @click="submmitFun">保 存</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

  </div>
</template>
<script>
import * as message from '../../api/message.js'
import Tinymce from '../../components/Tinymce'
export default {
  components: {
    Tinymce
  },
  data() {
    return {
      // 输入禁用
      disableIinput: false,

      rules: {

      },
      dialogBindData: {

      },
      // 按钮状态
      buttonState: false,
      delBtn: true,
      delIdArr: []
    }
  },

  beforeMount() {
    // 	  this.type = this.$route.params.type // 类型
    this.dialogBindData = this.$route.params.data // 编辑数据
    console.log(this.$route.params.data)
  },

  methods: {

    // 提交
    submmitFun() {
      const param = {
        'isConfigurable': 1,
        'memo': '订单免责',
        'paramKey': this.dialogBindData.paramKey,
        'paramName': this.dialogBindData.paramName,
        'paramValue': this.dialogBindData.paramValue
      }

      this.$refs.dialogBindData.validate((valid) => {
        if (valid) {
          message.updateMessage(param).then(res => {
            if (res.data.code !== 1) {
              this.$message({
                message: res.data.msg,
                type: 'warning'
              })
              this.buttonState = false
              return false
            }
            this.$message({
              message: '保存成功',
              type: 'success'
            })

            this.$router.push({
              name: '/v1/message'
            })
          })
        } else {
          return false
        }
      })
    }

  }
}
</script>
<style type="text/scss" lang="scss" scoped>
	.tinymcClass{

  }
</style>
